class Ruler(val board:Broad,val point:Int,val player1:Player,val player2:Player) {
    fun accept(player: Player): Boolean {
        if (board.array[player.chess.station.x - 1][player.chess.station.y - 1] == "⊙" || board.array[player.chess.station.x - 1][player.chess.station.y - 1] == "●") {
            println("输入重叠，请重新输入：")
            return true
        } else if (player.chess.station.x - 1 in 0..board.size - 1 && player.chess.station.y - 1 in 0..board.size - 1) {
            return false
        } else {
            println("输入越界，请重新输入：")
            return true
        }
    }

    fun win() {
        var num=0
        var array=board.array
        var size=board.size
        for (i in 0 until size) {
            for (j in 0 until size) {
                if(array[i][j]=="+"){
                    num++
                }
                if (array[i][j] == "⊙" || array[i][j] == "●") {
                    for (x in -1..1) {
                        for (y in -1..1) {
                            if (x != 0 || y != 0) {
                                if (i + point * x in 0..size-1 && j + (point) * y in 0..size-1) {
                                    var end=1;
                                    for (z in 1 .. point-1){
                                        if(array[i][j]==array[i + z * x][j +z * y ]){
                                            end++
                                        }
                                    }
                                    if(end==point){
                                        if(array[i][j]=="⊙"){
                                            println("黑棋胜利")
                                        }else if(array[i][j]=="●")
                                        {
                                            println("白棋胜利")
                                        }
                                        System.exit(0)
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if(num==0){
            println("和棋！游戏结束！")
            System.exit(0)
        }
    }
}